package com.nbjtjc.safe.api.emg.handle;

import com.nbjtjc.safe.bean.Page;
import com.nbjtjc.safe.bean.Result;
import com.nbjtjc.safe.mapper.emg.handle.EmgHandleReportMapper;
import com.nbjtjc.safe.model.emg.handle.EmgHandlePublic;
import com.nbjtjc.safe.model.emg.handle.EmgHandleReport;
import com.nbjtjc.safe.service.emg.handle.EmgHandleReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/emgHandleReport")
@CrossOrigin("*")
public class EmgHandleReportController {
    @Autowired
    private EmgHandleReportService emgHandleReportService;

    @Autowired
    private EmgHandleReportMapper emgHandleReportMapper;
    @RequestMapping(value = "/add",method = {RequestMethod.POST})
    public Result add(@RequestBody EmgHandleReport emgHandleReport){
        Result result=new Result();
        try {
            result=emgHandleReportService.add(emgHandleReport);
        } catch (Exception e) {
            e.printStackTrace();
            result.setFalse(e.getMessage());
        }
        return result;
    }
    @PostMapping(value = "/find")
    public Result find(@RequestBody EmgHandleReport emgHandleReport){
        Result result=new Result();
        try {
            result=emgHandleReportService.find(emgHandleReport);
        } catch (Exception e) {
            e.printStackTrace();
            result.setFalse(e.getMessage());
        }
        return result;
    }
    @RequestMapping(value = "/delete",method = {RequestMethod.POST})
    public Result delete(@RequestBody int id) {
        Result result=new Result();
        try {
            emgHandleReportMapper.deleteByPrimaryKey(id);
        } catch (Exception e) {
            e.printStackTrace();
            result.setFalse(e.getMessage());
        }
        return result;
    }

    @RequestMapping(value = "/update",method = {RequestMethod.POST})
    public Result update(@RequestBody EmgHandleReport emgHandleReport) {
        Result result=new Result();
        try {
            result=emgHandleReportService.update(emgHandleReport);
        } catch (Exception e) {
            e.printStackTrace();
            result.setFalse(e.getMessage());
        }
        return result;
    }
}
